import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../layout';

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue'),
    meta: {
      title: '登录'
    }
  },
  {
    path: '/',
    name: 'Home',
    redirect: '/login'
  },
  
  {
    path: '/allproject',
    name: 'AllProject',
    component: () => import('@/views/AllProject.vue'),
    meta: {
      title: '所有项目',
    }
  },
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: 'Help',
        name: 'Help',
        component: () => import('@/views/Help.vue'),
        meta: {
          title: '帮助文档',
        }
      },
      {
        path: 'Project',
        name: 'Project',
        component: () => import('@/views/Project.vue'),
        meta: {
          title: '项目首页',
          requireAuth: true
        }
      },
      {
        path: 'testCase',
        name: 'TestCase',
        component: () => import('@/views/TestCase.vue'),
        meta: {
          title: '用例管理',
          requireAuth: true
        }
      },
      {
        path: 'interfaceInfo',
        name: 'InterfaceInfo',
        component: () => import('@/views/Interface.vue'),
        meta: {
          title: '接口管理',
          requireAuth: true
        }
      },
      {
        path: 'task',
        name: 'Task',
        component: () => import('@/views/Task.vue'),
        meta: {
          title: '任务管理',
          requireAuth: true
        }
      },
      {
        path: 'testRecord',
        name: 'TestRecord',
        component: () => import('@/views/TestRecord.vue'),
        meta: {
          title: '运行记录',
          requireAuth: true
        }
      },
      {
        path: 'testReport',
        name: 'TestReport',
        component: () => import('@/views/TestReport.vue'),
        meta: {
          title: '测试报告'
        }
      },
      {
        path: 'dataAnalysis/:id?',
        name: 'DataAnalysis',
        component: () => import('@/views/DataAnalysis.vue'),
        meta: {
          title: '数据分析',
          requireAuth: true
        }
      },
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/User.vue'),
        meta: {
          title: '用户管理',
          requireAuth: true
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'hash',
  //base: process.env.BASE_URL,
  routes
})

export default router